<?php $tpl->addCSS('css/category.css'); ?>
<!-- Begin Category Content -->
<div id="category" class="ajaxadd">

  <h2><?php echo $heading_title; ?></h2>

  <div class="breadcrumb">
    <?php foreach ($breadcrumbs as $breadcrumb) { ?>
    <?php echo $breadcrumb['separator']; ?><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a>
    <?php } ?>
  </div>
  
  <?php if ($description) { ?>
  <div class="d"><?php echo $description; ?></div>
  <?php } ?>

  <!-- Subcategories -->
  <?php foreach (@$categories as $category) { ?>
  <div class="categories">
    <?php if ($category['thumb']) { ?>
      <a href="<?php echo $category['href']; ?>">
      <img src="<?php echo $category['thumb']; ?>" title="<?php echo $category['name']; ?>" alt="<?php echo $category['name']; ?>" />
      </a><br />
    <?php } ?> 
    <a href="<?php echo $category['href']; ?>"><?php echo $category['name']; ?></a>
  </div>
  <?php } ?>

  <!-- Products -->
  <?php if ($products) { ?>

  <?php if ($categories) { ?>
  <h2><?php echo $text_product; ?></h2>
  <?php } ?>

  <div class="results">
    <div class="left"><?php echo $text_results; ?></div>
    <div class="right pagination">
    <span class="entry_page"><?php echo $entry_page; ?></span>
    <?php foreach ($pages as $p) { ?>
    <a href="<?php echo $p['href']; ?>"<?php if ($p['value'] == $page) { ?> class="current"<?php } ?>><?php echo $p['value']; ?></a>
    <?php } ?>
    </div>
  </div>


  <div class="cat-products">
  <?php $j = 1; ?>
  <?php foreach ($products as $product) { ?>
  <?php if($j != 1) {$j = 1;}else{$j = 0;} ?>
  <?php if($j == 0) {$class = 'row1'; }elseif($j == 1){$class = 'row2';} ?>
    <form class="<?php echo $class; ?>" id="form_<?php echo $product['product_id']?>" name="form_<?php echo $product['product_id']?>" action="<?php echo $action; ?>" method="post" enctype="multipart/form-data">
      <input type="hidden" name="min_qty" value="<?php echo $product['min_qty']; ?>" />
      <input type="hidden" name="product_id" value="<?php echo $product['product_id']; ?>" />
    
	  <!-- div a -->
      <div class="a">
        <p class="clear"></p>
        <span class="thumb"><a href="<?php echo $product['href']; ?>"><img id="img_<?php echo $product['product_id']?>" src="<?php echo $product['thumb']; ?>" title="<?php echo $product['name']; ?>" alt="<?php echo $product['name']; ?>" /></a></span>
	  </div>
	
	  <!-- div b -->
	  <div class="b">
	    <div><span class="title"><a href="<?php echo $product['href']; ?>"><?php echo $product['name']; ?></a></span></div>
	    <div>
	      <span class="details">
          <?php if ($product['model']) {?><strong><?php echo $text_model; ?></strong><?php echo $product['model']; ?><br /><?php } ?>
          <?php if ($product['quantity']) {?><strong><?php echo $text_quantity; ?></strong><?php echo $product['quantity']; ?><br /><?php } ?>
	      </span>
	    </div>
	  
	    <?php if (@$product['description']) { ?>
	    <div class="description"><?php echo $product['description']; ?></div>
	    <?php } ?>  
	  
	    <?php if ($product['options']) { ?>
	    <div class="options">
  	      <div class="opt_title"><?php echo $text_options; ?></div>
  	      <table class="d">
		    <?php foreach ($product['options'] as $option) { ?>
		    <tr>
		      <td><?php echo $option['name']; ?>:</td>
		      <td>
     		    <select name="option[<?php echo $option['option_id']; ?>]">
				  <?php foreach ($option['value'] as $option_value) { ?>
                  <option value="<?php echo $option_value['product_to_option_id']; ?>"><?php echo $option_value['name']; ?>
		          <?php if ($option_value['price']) { ?> 
		          <?php echo $option_value['prefix']; ?><?php echo $option_value['price']; ?>
		          <?php } ?>
		  		  </option>
		          <?php } ?>
		        </select>
		      </td>
		    </tr>
		    <?php } //foreach options?>
		  </table>
		</div>
		<?php } //if options?>
      </div>
      
      <!-- div c --> 
      <div class="c">
        <?php if (isset($product['price_old'])) { ?>
	    <span class="reduce"><?php echo $product['price_old']; ?></span>
	    <span class="price price_new"><?php echo $product['price']; ?></span>
	    <?php } else { ?>
	    <span class="price"><?php echo $product['price']; ?></span>
	    <?php } ?>
	    <br />
	    <table>
          <tr>
		    <td><input type="text" name="quantity" value="<?php echo $product['min_qty']; ?>" size="3" /></td>
		    <td><?php echo $tpl->getImageButton('image/button_add_to_cart.gif', 'submit', $button_add_to_cart); ?></td>
		  </tr>
	    </table>
	    <?php if (isset($product['price_old'])) { ?>
	    <img src="<?php echo $tpl->getImage('image/sale.png'); ?>" alt="" />
	    <?php } ?>
	  </div>
    
    </form>
    <?php } ?>
  </div><!--eof products-->

  <div class="results">
    <div class="left"><?php echo $text_results; ?></div>
    <div class="right pagination">
    <span class="entry_page"><?php echo $entry_page; ?></span>
    <?php foreach ($pages as $p) { ?>
    <a href="<?php echo $p['href']; ?>"<?php if ($p['value'] == $page) { ?> class="current"<?php } ?>><?php echo $p['value']; ?></a>
    <?php } ?>
    </div>
  </div>
  <?php } ?>
  
  <?php echo @$latest; ?>

</div>